//******************************************************************
//******************************************************************
//**********          ANts Peer To Peer Sources        *************
//
// ANts P2P realizes a third generation P2P net. It protects your
// privacy while you are connected and makes you not trackable, hiding
// your identity (ip) and crypting everything you are sending/receiving
// from others.

// Copyright (C) 2004  Roberto Rossi

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

// to do jpanel4 is not removed, it should be, but now it is hidden
package ants.p2p.gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.MediaTracker;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Enumeration;

import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

import kerjodando.vincent.Common;

import org.apache.log4j.Logger;
import org.jibble.pircbot.User;

import ants.p2p.Ant;
import ants.p2p.NeighbourAnt;
import ants.p2p.filesharing.WarriorAnt;
import ants.p2p.messages.PrivateChatMessage;
import ants.p2p.messages.SecurityResponseMessage;
import ants.p2p.messages.security.MessageSigner;
import ants.p2p.query.ServerInfo;
import ants.p2p.query.security.AsymmetricProvider;
import ants.p2p.security.EndpointSecurityManager;
import ants.p2p.utils.addresses.InetAddressEngine;
import ants.p2p.utils.indexer.BackgroundEngine;
import ants.p2p.utils.misc.ConnectionClock;

import com.borland.jbcl.layout.XYConstraints;
import com.borland.jbcl.layout.XYLayout;

/**
 * This code was generated using CloudGarden's Jigloo SWT/Swing GUI Builder,
 * which is free for non-commercial use. If Jigloo is being used commercially
 * (ie, by a corporation, company or business for any purpose whatever) then you
 * should purchase a license for each developer using Jigloo. Please visit
 * www.cloudgarden.com for details. Use of Jigloo implies acceptance of these
 * licensing terms. ************************************* A COMMERCIAL LICENSE
 * HAS NOT BEEN PURCHASED for this machine, so Jigloo or this code cannot be
 * used legally for any corporate or commercial purpose.
 * *************************************
 */
public class ConnectionAntPanel extends JPanel implements
		PropertyChangeListener {
	// public static String lastRoutingPoint = "";
	// public static int lastRoutingPointPort = 443;
	// public static String nick = "Kerj"+(int)(Math.random()*1000000);
	/*
	 * public static String ircServer = ""; public static String ircChannel =
	 * "#ANtsP2P"; public static int ircPort = 6666; public static boolean
	 * autoReconnectIRC = false; public static boolean searchPeersOnIRC = true;
	 */
	boolean firewallChecked = false;

	public static final double MegaByte = Math.pow(2, 20);

	private ConnectionClock clock = new ConnectionClock(this);

	public static String pic = "backgrounds/bg0.jpg";

	static Logger _logger = Logger
			.getLogger(ConnectionAntPanel.class.getName());

	public PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(
			this);

	// InetAddress localAddress = null;
	String localStringAddress;

	ConnectionManager connectionManager = null;
	Image buffer;
	//JLabel jLabel1 = new JLabel();
	//JList jList1;
	JList jList2;
	XYLayout xYLayout1 = new XYLayout();
	JLabel jLabel2 = new JLabel();
	JTextField jTextField1 = new JTextField();
	JTextField jTextField2 = new JTextField();
	JLabel jLabel3 = new JLabel();
	JLabel jLabel4 = new JLabel();
	JButton jButton1 = new JButton();
	//JButton jButton2 = new JButton();
	JButton jButton3 = new JButton();
	JLabel jLabel5 = new JLabel();
	JTextField jTextField3 = new JTextField();

	// add by vincent.zhu to update port to server
	public String getPort() {
		return this.jTextField3.getText();
	}

	// end add
	JLabel jLabel6 = new JLabel();
	/*
	 * JTextField jTextField4 = new JTextField(); JLabel jLabel7 = new JLabel();
	 */
	GuiAnt container;

	public WarriorAnt warriorAnt;
	// public IrcBot ircBot;
	//JScrollPane jScrollPane1 = new JScrollPane();
	DefaultListModel neighbours = new DefaultListModel();
	DefaultListModel secureConnections = new DefaultListModel();
	JLabel jLabel9 = new JLabel();
	JLabel jLabel10 = new JLabel();
	JLabel jLabel11 = new JLabel();
	JScrollPane jScrollPane2 = new JScrollPane();
	JLabel jLabel13 = new JLabel();
	JButton jButton4 = new JButton();
	JButton jButton5 = new JButton();
	JButton jButton6 = new JButton();
	JButton jButton7 = new JButton();
	/*
	 * JScrollPane jScrollPane3 = new JScrollPane(); JList jList3 = new JList();
	 * JLabel jLabel14 = new JLabel(); JButton jButton8 = new JButton();
	 */
	/*
	 * JTextField jTextField5 = new JTextField(); JTextField jTextField6 = new
	 * JTextField(); JLabel jLabel15 = new JLabel(); JLabel jLabel16 = new
	 * JLabel();
	 */
	// JButton jButton9 = new JButton();
	//JCheckBox jCheckBox1 = new JCheckBox();
	JPanel jPanel1 = new JPanel();
	XYLayout xYLayout2 = new XYLayout();
	TitledBorder titledBorder1;
	TitledBorder titledBorder2;
	JPanel jPanel2 = new JPanel();
	XYLayout xYLayout3 = new XYLayout();
	Border border1;
	JPanel jPanel3 = new JPanel();
	XYLayout xYLayout4 = new XYLayout();
	JPanel jPanel4 = new JPanel();
	XYLayout xYLayout5 = new XYLayout();
	JLabel jLabel12 = new JLabel();
	JButton jButton10 = new JButton();
	JLabel jLabel17 = new JLabel();
	JScrollPane jScrollPane4 = new JScrollPane();
	JList jList4 = new JList();
	JTextField jTextField7 = new JTextField();
	JTextField jTextField8 = new JTextField();
	JButton jButton11 = new JButton();
	JButton jButton12 = new JButton();
	JLabel jLabel18 = new JLabel();
	JLabel jLabel19 = new JLabel();
	JLabel jLabel22 = new JLabel();
	JLabel jLabel23 = new JLabel();
	JPanel jPanel5 = new JPanel();
	JLabel jLabel8 = new JLabel();
	XYLayout xYLayout6 = new XYLayout();
	JLabel jLabel24 = new JLabel();
	JLabel jLabel25 = new JLabel();
	JLabel jLabel26 = new JLabel();
	JLabel jLabel27 = new JLabel();
	JLabel jLabel28 = new JLabel();
	JLabel jLabel29 = new JLabel();
	JLabel jLabel30 = new JLabel();
	JLabel jLabel31 = new JLabel();
	JLabel jLabel32 = new JLabel();
	JLabel jLabel33 = new JLabel();
	JPanel jPanel6 = new JPanel();
	XYLayout xYLayout7 = new XYLayout();
	JPanel jPanel7 = new JPanel();
	XYLayout xYLayout8 = new XYLayout();
	JPanel jPanel8 = new JPanel();
	XYLayout xYLayout9 = new XYLayout();
	JPanel jPanel9 = new JPanel();
	XYLayout xYLayout10 = new XYLayout();
	JButton jButton13 = new JButton();
	JCheckBox jCheckBox2 = new JCheckBox();
	JCheckBox jCheckBox3 = new JCheckBox();
	JCheckBox jCheckBox4 = new JCheckBox();

	public ConnectionAntPanel(GuiAnt container) {
		// this.ircChannel = this.ircChannel.toLowerCase();
		this.container = container;
		try {
			Toolkit tk = Toolkit.getDefaultToolkit();
			MediaTracker mt = new MediaTracker(this);
			buffer = tk.getImage(this.getClass().getClassLoader().getResource(
					pic));
			mt.waitForAll();
		} catch (Exception e) {
		}
		try {
			jbInit();
		} catch (Exception ex) {
			_logger.error("", ex);
		}
		//this.jCheckBox1.setSelected(false);
		this.jPanel4.setVisible(false);
		this.jList4.setListData(InetAddressEngine.getInstance()
				.getTrustedPeers().toArray());
	}

	void jbInit() throws Exception {
		clock.start();
		//jList1 = new JList(neighbours);
		jList2 = new JList(secureConnections);
		titledBorder1 = new TitledBorder("");
		titledBorder2 = new TitledBorder("");
		border1 = BorderFactory.createEmptyBorder(20, 20, 20, 20);
		/*by casper 08.04.17
		jLabel1.setForeground(Color.black);
		jLabel1.setText(ji.JI.i("Connected Kerjos"));
		*/
		this.setLayout(xYLayout1);
		jLabel2.setForeground(Color.black);
		jLabel2.setText(ji.JI.i("Connect to"));
		jTextField2.setMaximumSize(new Dimension(60, 2147483647));
		jTextField2.setMinimumSize(new Dimension(60, 21));
		jTextField2.setPreferredSize(new Dimension(60, 21));
		jTextField2.setText(Common.port);
		jTextField2
				.addFocusListener(new ConnectionAntPanel_jTextField2_focusAdapter(
						this));
		jLabel3.setForeground(Color.black);
		jLabel3.setText(ji.JI.i("Neighbour Address"));
		jLabel4.setForeground(Color.black);
		jLabel4.setText(ji.JI.i("Port"));
		jButton1.setEnabled(false);
		jButton1.setVerifyInputWhenFocusTarget(true);
		jButton1.setText(ji.JI.i("Connect..."));
		jButton1
				.addActionListener(new ConnectionAntPanel_jButton1_actionAdapter(
						this));
		xYLayout1.setWidth(1059);
		xYLayout1.setHeight(580);
		/*
		jButton2.setEnabled(false);
		jButton2
				.setToolTipText(ji.JI
						.i("Disconnects a neighbour, this may cause some routes to result broken"));
		jButton2.setText(ji.JI.i("Disconnect"));
		jButton2
				.addActionListener(new ConnectionAntPanel_jButton2_actionAdapter(
						this));
						*/
		jButton3.setMaximumSize(new Dimension(150, 50));
		jButton3.setMinimumSize(new Dimension(150, 50));
		jButton3.setPreferredSize(new Dimension(150, 50));
		jButton3.setToolTipText(ji.JI.i("Start ANts"));
		jButton3.setIcon(new LabelIcon(ji.JI.i("Start ANts"), DoubleBuffer
				.getInstance().getButton(11), jButton3));
		jButton3
				.addActionListener(new ConnectionAntPanel_jButton3_actionAdapter(
						this));
		jLabel5.setForeground(Color.black);
		jLabel5.setText(ji.JI.i("Ant not running..."));
		jTextField3.setMaximumSize(new Dimension(60, 2147483647));
		jTextField3.setMinimumSize(new Dimension(60, 21));
		jTextField3.setOpaque(true);
		jTextField3.setPreferredSize(new Dimension(60, 21));
		jTextField3
				.setToolTipText(ji.JI
						.i("The port ANts will run on. Be sure that this is not firewalled as "
								+ "well as the next one shoulnd\'t be for good performances"));
		jTextField3.setVerifyInputWhenFocusTarget(true);
		jTextField3.setText(Common.port);
		jTextField3
				.addFocusListener(new ConnectionAntPanel_jTextField3_focusAdapter(
						this));
		jLabel6.setForeground(Color.black);
		jLabel6.setText(ji.JI.i("Port"));
		/*
		 * jTextField4.setMaximumSize(new Dimension(100, 2147483647));
		 * jTextField4.setMinimumSize(new Dimension(100, 21));
		 * jTextField4.setOpaque(true); jTextField4.setPreferredSize(new
		 * Dimension(100, 21)); jTextField4.setToolTipText(ji.JI.i("The nick you
		 * are going to use on IRC")); jTextField4.setSelectionStart(0);
		 * this.jTextField4.setText(ConnectionAntPanel.nick);
		 * jTextField4.addFocusListener(new
		 * ConnectionAntPanel_jTextField4_focusAdapter(this));
		 * jLabel7.setForeground(Color.black); jLabel7.setText(ji.JI.i("Nick"));
		 */

		/*jScrollPane1
				.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		jScrollPane1.setBorder(BorderFactory.createEtchedBorder());
		*/
		jLabel9.setForeground(Color.black);
		jLabel9
				.setToolTipText(ji.JI
						.i("The ip Kerjodando have detected for your PC, it can be not a valid Internet "
								+ "IP so please check!"));
		jLabel9.setVerifyInputWhenFocusTarget(true);
		jLabel9.setText("IP: ");
		jLabel10.setText(ji.JI.i("Neighbours connection"));
		jLabel11.setForeground(Color.black);
		jLabel11.setText(ji.JI.i("Neighbours connections"));
		jLabel13.setForeground(Color.black);
		jLabel13.setVerifyInputWhenFocusTarget(true);
		jLabel13.setText(ji.JI.i("Avaiable secure output connections"));
		jScrollPane2.setBorder(BorderFactory.createEtchedBorder());
		jButton4.setEnabled(false);
		jButton4.setPreferredSize(new Dimension(109, 23));
		jButton4
				.setToolTipText(ji.JI
						.i("Removing a secure connection may result in some download aborts if "
								+ "the removed connection is active"));
		jButton4.setText("Remove Secure");
		jButton4
				.addActionListener(new ConnectionAntPanel_jButton4_actionAdapter(
						this));
		jButton5.setEnabled(false);
		jButton5.setMaximumSize(new Dimension(150, 50));
		jButton5.setMinimumSize(new Dimension(150, 50));
		jButton5.setPreferredSize(new Dimension(150, 50));
		jButton5
				.setToolTipText(ji.JI
						.i("Click here to perform a new search... If this is disabled you may have to wait for a connection"));
		jButton5.setMargin(new Insets(2, 14, 2, 14));
		// jButton5.setText(ji.JI.i("New Query"));
		jButton5.setIcon(new LabelIcon(ji.JI.i("New Query"), DoubleBuffer
				.getInstance().getButton(12), jButton5));
		jButton5
				.addActionListener(new ConnectionAntPanel_jButton5_actionAdapter(
						this));
		jButton6.setMaximumSize(new Dimension(150, 50));
		jButton6.setMinimumSize(new Dimension(150, 50));
		jButton6.setPreferredSize(new Dimension(150, 50));
		jButton6.setToolTipText(ji.JI
				.i("Access to the ANts p2p general settings"));
		jButton6.setIcon(new LabelIcon(ji.JI.i("Settings"), DoubleBuffer
				.getInstance().getButton(7), jButton6));
		jButton6.setText("");
		// jButton6.setText(ji.JI.i("Settings"));
		jButton6
				.addActionListener(new ConnectionAntPanel_jButton6_actionAdapter(
						this));
		jButton7.setMaximumSize(new Dimension(100, 25));
		jButton7.setMinimumSize(new Dimension(100, 25));
		jButton7.setPreferredSize(new Dimension(100, 25));
		jButton7.setIcon(new LabelIcon(ji.JI.i("Advanced"), DoubleBuffer
				.getInstance().getButton(4), jButton7));
		// jButton7.setText(ji.JI.i("Advanced"));
		jButton7
				.addActionListener(new ConnectionAntPanel_jButton7_actionAdapter(
						this));
		jButton7.setVisible(false);
		/*
		 * jLabel14.setForeground(Color.black); jLabel14.setText(ji.JI.i("Peers
		 * with free slots")); jButton8.setEnabled(false);
		 * jButton8.setText(ji.JI.i("Refresh")); jButton8.addActionListener(new
		 * ConnectionAntPanel_jButton8_actionAdapter(this));
		 */
		/*
		 * jTextField5.setMaximumSize(new Dimension(200, 2147483647));
		 * jTextField5.setMinimumSize(new Dimension(200, 21));
		 * jTextField5.setOpaque(true); jTextField5.setPreferredSize(new
		 * Dimension(200, 21));
		 * jTextField5.setText(ConnectionAntPanel.lastRoutingPoint);
		 * jTextField6.setOpaque(true); jTextField6.setText(Common.port);
		 * jTextField6.addFocusListener(new
		 * ConnectionAntPanel_jTextField6_focusAdapter(this));
		 * jLabel15.setForeground(Color.black);
		 * jLabel15.setText(ji.JI.i("Routing Point Addr..."));
		 * jLabel16.setForeground(Color.black);
		 * jLabel16.setText(ji.JI.i("Port"));
		 */
		/*
		 * jList3.addMouseListener(new
		 * ConnectionAntPanel_jList3_mouseAdapter(this));
		 * jList3.setOpaque(true);
		 * jList3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		 * jScrollPane3.setBorder(BorderFactory.createEtchedBorder());
		 * jScrollPane3.setDebugGraphicsOptions(0);
		 */
		/*
		 * jButton9.setEnabled(false); jButton9.setText(ji.JI.i("Find Routing
		 * Point")); jButton9.addActionListener(new
		 * ConnectionAntPanel_jButton9_actionAdapter(this));
		 */
		/*
		jCheckBox1.setForeground(Color.black);
		jCheckBox1.setMaximumSize(new Dimension(220, 23));
		jCheckBox1.setMinimumSize(new Dimension(220, 23));
		jCheckBox1.setOpaque(false);
		jCheckBox1.setPreferredSize(new Dimension(150, 23));
		jCheckBox1.setToolTipText(ji.JI.i("Developer\'s section"));
		jCheckBox1.setText(ji.JI.i("Advanced Mode"));
		jCheckBox1
				.addActionListener(new ConnectionAntPanel_jCheckBox1_actionAdapter(
						this));
		jCheckBox1.setSelected(true);
		*/
		/*jList1.setOpaque(true);
		jList1
				.setToolTipText(ji.JI
						.i("These are your current neighbours, that is other nodes you are directly "
								+ "connected to"));
								*/
		jList2.setOpaque(true);
		jList2
				.setToolTipText(ji.JI
						.i("These are your avaiable secure connections with other ANts P2P peers"));
		jTextField1.setOpaque(true);
		jPanel1.setBorder(BorderFactory.createEtchedBorder());
		jPanel1.setDebugGraphicsOptions(0);
		jPanel1.setDoubleBuffered(true);
		jPanel1.setMaximumSize(new Dimension(256, 386));
		jPanel1.setMinimumSize(new Dimension(256, 386));
		jPanel1.setPreferredSize(new Dimension(256, 386));
		jPanel1.setLayout(xYLayout2);
		jPanel2.setLayout(xYLayout3);
		jPanel2.setBorder(BorderFactory.createEtchedBorder());
		jPanel2.setMaximumSize(new Dimension(2147483647, 115));
		jPanel2.setMinimumSize(new Dimension(342, 150));
		jPanel2.setPreferredSize(new Dimension(342, 150));
		this.setBorder(border1);
		this.setPreferredSize(new Dimension(1099, 650));
		this.addComponentListener(new ConnectionAntPanel_this_componentAdapter(
				this));
		jPanel3.setBorder(BorderFactory.createEtchedBorder());
		jPanel3.setDebugGraphicsOptions(0);
		jPanel3.setMaximumSize(new Dimension(2147483647, 120));
		jPanel3.setMinimumSize(new Dimension(460, 120));
		jPanel3.setPreferredSize(new Dimension(703, 120));
		jPanel3.setLayout(xYLayout4);
		jPanel4.setLayout(xYLayout5);
		jPanel4.setBorder(BorderFactory.createEtchedBorder());
		jPanel4.setMaximumSize(new Dimension(365, 335));
		jPanel4.setMinimumSize(new Dimension(365, 335));
		jPanel4.setPreferredSize(new Dimension(600, 335));
		jLabel12
				.setToolTipText(ji.JI
						.i("This is your ID inside the ANts network, it\'s very important to keep "
								+ "it secret"));
		jLabel12.setText("ID: ");
		jButton10.setMaximumSize(new Dimension(150, 50));
		jButton10.setMinimumSize(new Dimension(150, 50));
		jButton10.setPreferredSize(new Dimension(150, 50));
		jButton10.setToolTipText(ji.JI
				.i("Manage your shared files and folders"));
		// jButton10.setText(ji.JI.i("Shared Files"));
		jButton10.setIcon(new LabelIcon(ji.JI.i("Shared Files"), DoubleBuffer
				.getInstance().getButton(20), jButton10));
		jButton10
				.addActionListener(new ConnectionAntPanel_jButton10_actionAdapter(
						this));
		jLabel17.setText(ji.JI.i("Trusted Peers"));
		jTextField7.setText("");
		jTextField8.setText("");
		jTextField8
				.addFocusListener(new ConnectionAntPanel_jTextField8_focusAdapter(
						this));
		jButton11.setText(ji.JI.i("Add Trusted Peer"));
		jButton11
				.addActionListener(new ConnectionAntPanel_jButton11_actionAdapter(
						this));
		jButton12.setText(ji.JI.i("Remove Trusted Peer"));
		jButton12
				.addActionListener(new ConnectionAntPanel_jButton12_actionAdapter(
						this));
		jLabel18.setText(ji.JI.i("Trusted Peer Address"));
		jLabel19.setText(ji.JI.i("Port"));
		jLabel22.setToolTipText(ji.JI.i("This is your active connection time"));
		jLabel22.setText("0:0:0");
		jLabel23.setText(ji.JI.i("Firewall probing idle"));
		jLabel23.setToolTipText("<html><body>"
				+ ji.JI.i("The test process for your port status is idle... ")
				+ "</body></html>");
		jLabel23.setForeground(Color.RED);
		jPanel5.setBorder(BorderFactory.createEtchedBorder());
		jPanel5.setLayout(xYLayout6);
		jLabel8.setText(ji.JI.i("Download"));
		jLabel24.setToolTipText(ji.JI
				.i("This is the compression rate of your incoming datas"));
		jLabel24.setText("0 %");
		jLabel25.setText(ji.JI.i("Upload"));
		jLabel26.setToolTipText(ji.JI
				.i("This is the compression rate of outcoming datas"));
		jLabel26.setText("0 %");
		jLabel27.setToolTipText(ji.JI.i("This is the total inbound traffic"));
		jLabel27.setText("0 MB");
		jLabel28.setToolTipText(ji.JI.i("This is the total outbound traffic"));
		jLabel28.setText("0 MB");
		jLabel29.setToolTipText(ji.JI
				.i("This is the amount of traffic regarding your downloads"));
		jLabel29.setText("0 MB");
		jLabel30.setToolTipText(ji.JI
				.i("This is the amount of traffic regarding your uploads"));
		jLabel30.setText("0 MB");
		jLabel31.setText(ji.JI.i("Compressed"));
		jLabel32.setText(ji.JI.i("Total traffic"));
		jLabel33.setText(ji.JI.i("Own traffic"));
		jPanel6.setBorder(BorderFactory.createEtchedBorder());
		jPanel6.setDebugGraphicsOptions(0);
		jPanel6.setLayout(xYLayout7);
		jPanel7.setBorder(BorderFactory.createEtchedBorder());
		jPanel7.setDebugGraphicsOptions(0);
		jPanel7.setLayout(xYLayout8);
		jPanel8.setBorder(BorderFactory.createEtchedBorder());
		jPanel8.setLayout(xYLayout9);
		jPanel9.setBorder(BorderFactory.createEtchedBorder());
		jPanel9.setToolTipText(ji.JI.i("This is the status bar"));
		jPanel9.setLayout(xYLayout10);
		jButton13.setEnabled(false);
		jButton13.setMaximumSize(new Dimension(109, 23));
		jButton13.setMinimumSize(new Dimension(109, 23));
		jButton13.setPreferredSize(new Dimension(109, 23));
		jButton13.setText(ji.JI.i("Private chat"));
		jButton13
				.addActionListener(new ConnectionAntPanel_jButton13_actionAdapter(
						this));
		jCheckBox2.setText("Non anonymous mode");
		jCheckBox2
				.addActionListener(new ConnectionAntPanel_jCheckBox2_actionAdapter(
						this));
		jCheckBox3.setText(ji.JI.i("Proxied"));
		jCheckBox3.setSelected(Ant.proxied);
		jCheckBox3
				.addActionListener(new ConnectionAntPanel_jCheckBox3_actionAdapter(
						this));
		jCheckBox3.setToolTipText(ji.JI.i("Set your proxy address"));
		jCheckBox4.setText(ji.JI.i("UPnP"));
		jCheckBox4.setSelected(true);
		jCheckBox4.setToolTipText(ji.JI
				.i("Set ANts as a UPnP device on the LAN"));
		/*08.04.17
		jPanel1.add(jLabel1, new XYConstraints(10, 10, 155, -1));
		jPanel1.add(jScrollPane1, new XYConstraints(10, 30, 230, 120));
		jPanel1.add(jButton2, new XYConstraints(10, 155, -1, -1));
		jPanel1.add(jScrollPane2, new XYConstraints(10, 220, 230, 120));
		jPanel1.add(jLabel13, new XYConstraints(10, 200, -1, -1));
		jPanel1.add(jButton4, new XYConstraints(10, 346, -1, -1));
		jPanel1.add(jButton13, new XYConstraints(132, 346, -1, -1));
		*/
		jPanel1.add(jLabel13, new XYConstraints(10, 10, -1, -1));
		jPanel1.add(jScrollPane2, new XYConstraints(10, 30, 230, 120));
		jPanel1.add(jButton4, new XYConstraints(10, 156, -1, -1));
		jPanel1.add(jButton13, new XYConstraints(132, 156, -1, -1));
		jScrollPane2.getViewport().add(jList2, null);
		//jScrollPane1.getViewport().add(jList1, null);
		this.add(jPanel4, new XYConstraints(258, 16, -1, -1));
		// jPanel4.add(jLabel14, new XYConstraints(10, 10, -1, -1));
		// jPanel4.add(jScrollPane3, new XYConstraints(10, 30, 170, 174));
		// jPanel4.add(jTextField5, new XYConstraints(10, 260, 116, -1));
		// jPanel4.add(jTextField6, new XYConstraints(140, 260, 49, -1));
		jPanel4.add(jLabel11, new XYConstraints(210, 10, -1, -1));
		// jPanel4.add(jButton9, new XYConstraints(10, 290, 150, -1));
		jPanel4.add(jLabel2, new XYConstraints(210, 40, -1, -1));
		jPanel4.add(jLabel3, new XYConstraints(210, 60, -1, -1));
		jPanel4.add(jTextField1, new XYConstraints(210, 80, 125, -1));
		jPanel4.add(jLabel4, new XYConstraints(210, 110, -1, -1));
		jPanel4.add(jTextField2, new XYConstraints(210, 130, -1, -1));
		jPanel4.add(jButton1, new XYConstraints(210, 180, 105, -1));
		// jPanel4.add(jLabel15, new XYConstraints(10, 240, -1, -1));
		// jPanel4.add(jLabel16, new XYConstraints(140, 240, -1, -1));
		// jPanel4.add(jButton8, new XYConstraints(10, 210, -1, -1));
		jPanel4.add(jLabel17, new XYConstraints(400, 10, -1, -1));
		jPanel4.add(jScrollPane4, new XYConstraints(400, 30, 170, 174));
		jPanel4.add(jTextField7, new XYConstraints(400, 260, 116, -1));
		jPanel4.add(jTextField8, new XYConstraints(530, 260, 49, -1));
		jPanel4.add(jButton11, new XYConstraints(400, 290, 150, -1));
		jPanel4.add(jButton12, new XYConstraints(400, 210, 150, -1));
		jPanel4.add(jLabel18, new XYConstraints(400, 240, -1, -1));
		jPanel4.add(jLabel19, new XYConstraints(530, 240, -1, -1));
		jScrollPane4.getViewport().add(jList4, null);
		// jScrollPane3.getViewport().add(jList3, null);
		this.add(jPanel1, new XYConstraints(-2, 15, -1, -1));
		jPanel5.add(jLabel8, new XYConstraints(140, 2, -1, -1));
		jPanel5.add(jLabel24, new XYConstraints(140, 32, -1, -1));
		jPanel5.add(jLabel25, new XYConstraints(230, 2, -1, -1));
		jPanel5.add(jLabel26, new XYConstraints(230, 32, -1, -1));
		jPanel5.add(jLabel27, new XYConstraints(140, 52, -1, -1));
		jPanel5.add(jLabel28, new XYConstraints(230, 52, -1, -1));
		jPanel5.add(jLabel29, new XYConstraints(140, 72, -1, -1));
		jPanel5.add(jLabel30, new XYConstraints(230, 72, -1, -1));
		jPanel5.add(jLabel31, new XYConstraints(5, 32, -1, -1));
		jPanel5.add(jLabel32, new XYConstraints(5, 52, -1, -1));
		jPanel5.add(jLabel33, new XYConstraints(5, 72, -1, -1));
		jPanel2.add(jPanel9, new XYConstraints(95, 5, 345, 40));
		jPanel9.add(jLabel5, new XYConstraints(5, 2, -1, -1));
		// jPanel9.add(jLabel23, new XYConstraints(5, 18, -1, -1));
		jPanel2.add(jPanel7, new XYConstraints(95, 80, 140, 25));
		jPanel7.add(jLabel12, new XYConstraints(5, 2, -1, -1));
		jPanel2.add(jPanel8, new XYConstraints(95, 50, 140, 25));
		jPanel8.add(jLabel9, new XYConstraints(5, 2, -1, -1));
		jPanel2.add(jPanel5, new XYConstraints(240, 50, 300, 95));
		jPanel2.add(jPanel6, new XYConstraints(95, 120, 140, 25));
		jPanel6.add(jLabel22, new XYConstraints(5, 2, -1, -1));
		if (this.container.animationPanel != null) {
			jPanel2.add(this.container.animationPanel, new XYConstraints(5, 5,
					80, 100));
		}
		this.add(jPanel3, new XYConstraints(11, 415, -1, -1));
		jPanel3.add(jTextField3, new XYConstraints(10, 30, -1, -1));
		jPanel3.add(jLabel6, new XYConstraints(10, 10, -1, -1));
		// jPanel3.add(jLabel7, new XYConstraints(100, 10, -1, -1));
		// jPanel3.add(jTextField4, new XYConstraints(100, 30, -1, -1));
		jPanel3.add(jButton5, new XYConstraints(250, 10, -1, -1));
		jPanel3.add(jButton3, new XYConstraints(10, 60, -1, -1));
		//jPanel3.add(jCheckBox1, new XYConstraints(170, 90, -1, -1));
		jPanel3.add(jButton7, new XYConstraints(320, 70, -1, -1));
		jPanel3.add(jButton6, new XYConstraints(410, 10, -1, -1));
		jPanel3.add(jButton10, new XYConstraints(570, 10, -1, -1));
		jPanel3.add(jCheckBox2, new XYConstraints(170, 60, -1, -1));
		//jPanel3.add(jCheckBox3, new XYConstraints(410, 90, -1, -1));
		//jPanel3.add(jCheckBox4, new XYConstraints(570, 90, -1, -1));
		jPanel3.add(jCheckBox3, new XYConstraints(170, 90, -1, -1));
		jPanel3.add(jCheckBox4, new XYConstraints(330, 90, -1, -1));
		this.add(jPanel2, new XYConstraints(463, 394, 533, 156)); // this.setIrcUsersNumberInChannel(-1,
		// "");
	}

	/*
	 * public void setIrcUsersNumberInChannel(int number, String channel){
	 * if(number > 0){ this.jLabel8.setText("Users in the chatroom "+channel+": " +
	 * number); }else if(number == 0){ this.jLabel8.setText("No users in the
	 * chatroom"); }else{ this.jLabel8.setText("IRC client not connected"); } }
	 */
	/*
	 * public void setRoutingPoint(InetAddress address, int port){
	 * _logger.info("Setting routing point:
	 * "+address.getHostAddress()+":"+port);
	 * this.jTextField5.setText(address.getHostAddress());
	 * this.jTextField6.setText(port+""); }
	 */
	public boolean isFirewallChecked() {
		return this.firewallChecked;
	}

	public void setFirewallState(boolean up) {
		this.firewallChecked = true;
		if (up) {
			this.jLabel23
					.setText(ji.JI
							.i("Your Firewall is UP or you are behind a NAT! Please check it!"));
			this.jLabel23
					.setToolTipText("<html><body><i>"
							+ ji.JI.i("Important note")
							+ "</i><br>"
							+ ji.JI
									.i("This message means ANts is working in a way that prevents incoming connections from other peers.<br>This problem can derive from a wrong IP set in the settings panel<br>or it can be due to your firewall that prevents connections to the port ")
							+ this.warriorAnt.getServerPort()
							+ ji.JI
									.i(".<br>This doesn't mean you can't use ANts, ANts will work anyway but probably it will take longer to make connections.<br>If you are not sure please don't care to much about this message.")
							+ "</body></html>");
			this.jLabel23.setForeground(Color.RED);
		} else {
			this.jLabel23.setText(ji.JI.i("Your Firewall is correctly set!"));
			this.jLabel23
					.setToolTipText("<html><body>"
							+ ji.JI
									.i("Kerjo is working properly on the selected port: ")
							+ this.warriorAnt.getServerPort()
							+ "</body></html>");
			this.jLabel23.setForeground(Color.BLUE);
		}
	}

	public GuiAnt getContainer() {
		return this.container;
	}

	public WarriorAnt getWarriorAnt() {
		return this.warriorAnt;
	}

	/*
	 * public JButton getJButton9(){ return this.jButton9; }
	 */
	/*
	 * public static String getNick(){ return "casper"; // return nick; }
	 */
	public void propertyChange(final PropertyChangeEvent e) {
		handleEvent(e);
		/*
		 * Thread handler = new Thread(){ public void run(){ handleEvent(e); } };
		 * handler.start(); try { handler.join(); } catch (InterruptedException
		 * ex) { }
		 */
	}

	public synchronized void checkNeighboursConsistency() {
		for (int i = this.neighbours.size() - 1; i >= 0; i--) {
			if (this.warriorAnt.getNeighbour(((NeighbourAnt) this.neighbours
					.get(i)).getIdent()) == null) {
				this.neighbours.remove(i);
				if (this.neighbours.size() == 0) {
					this.clock.count(false);
					this.jButton5.setEnabled(false);
					_logger.info("Removing QAPs...");
					for (int x = this.container.queryPanels.size() - 1; x >= 0; x--) {
						QueryAntPanel qap = (QueryAntPanel) this.container.queryPanels
								.remove(x);
						this.container.jTabbedPane1.remove(qap);
						this.warriorAnt.getPropertyChangeSupport()
								.removePropertyChangeListener(qap);
					}
					_logger.info("Removing DAP: " + this.container.dap);
					if (this.container.dap != null) {
						_logger.info("Interrupting downloads");
						this.container.dap.interruptAllDownloads();
						_logger.info("Interrupted!");
						this.container.jTabbedPane1.remove(this.container.dap);
						this.warriorAnt.getPropertyChangeSupport()
								.removePropertyChangeListener(
										this.container.dap);
						this.container.dap = null;
					}
					_logger.info("Removing UAP: " + this.container.uap);
					if (this.container.uap != null) {
						_logger.info("Interrupting uploads");
						this.container.uap.interruptAllUploads();
						_logger.info("Interrupted!");
						this.container.jTabbedPane1.remove(this.container.uap);
						this.warriorAnt.getPropertyChangeSupport()
								.removePropertyChangeListener(
										this.container.uap);
						this.container.uap = null;
					}
					/*
					 * 07-07-08 _logger.info("Removing HAP:
					 * "+this.container.httpPanel); if (this.container.httpPanel !=
					 * null) {
					 * this.container.jTabbedPane1.remove(this.container.httpPanel);
					 * this.warriorAnt.getPropertyChangeSupport().
					 * removePropertyChangeListener( this.container.httpPanel);
					 * this.warriorAnt.resetCurrentProxy();
					 * this.container.httpPanel = null; }
					 */
					if (container.animationPanel != null) {
						this.container.animationPanel.stop();
					}
					this.container.revalidate();
				}
				if (this.container != null
						&& this.container.jTabbedPane1 != null) {
					Component[] tabs = this.container.jTabbedPane1
							.getComponents();
					for (int x = 0; tabs != null && x < tabs.length; x++) {
						if (tabs[x] == this.container.connectionScrollPane) {
							if (this.neighbours.size() > 0) {
								this.container.jTabbedPane1
										.setIconAt(
												x,
												new LabelIcon(
														ji.JI.i("Connected")
																+ " ["
																+ ji.JI
																		.i("Peers")
																+ ": "
																+ this.neighbours
																		.size()
																+ "]",
														DoubleBuffer
																.getInstance()
																.getButton(19),
														this.container.connectionScrollPane));
							} else {
								this.container.jTabbedPane1
										.setIconAt(
												x,
												new LabelIcon(
														ji.JI
																.i("Wait! ANts is connecting..."),
														DoubleBuffer
																.getInstance()
																.getButton(19),
														this.container.connectionScrollPane));
							}
						}
					}
				}
			}
		}
	}

	public void handleEvent(PropertyChangeEvent e) {
		if (e.getPropertyName().equals("privateChatMessageReceived")) {
			PrivateChatMessage pcm = (PrivateChatMessage) e.getNewValue();
			PrivateChatFrame pcf = (PrivateChatFrame) PrivateChatFrame
					.getChatWith(pcm.getSource(), this.warriorAnt, false);
			ants.p2p.security.EndpointSecurityManager esm = pcf.initiator ? this.warriorAnt
					.getOutputSecureConnectionManager(pcm.getSource())
					: this.warriorAnt.getInputSecureConnectionManager(pcm
							.getSource());
			if (esm == null) {
				if (pcf.initiator) {
					this.warriorAnt.propertyChangeSupport.firePropertyChange(
							"securityConnectionError", pcm.getSource(), pcm);
				}
				_logger.error("No secure connection avaiable with endpoint "
						+ pcm.getSource());
				return;
			}
			try {
				pcm.decrypt(esm.getCipherDec());
				pcf.insertExternalMessage(pcm.getContent());
				pcf.show();
				pcf.transferFocus();
			} catch (Exception ex) {
				_logger.error("Error in handling private message from: "
						+ pcm.getSource().substring(0, 10), ex);
			}
		}
		if (e.getPropertyName().equals("removedNeighbour")) {
			NeighbourAnt na = (NeighbourAnt) e.getNewValue();
			synchronized (this) {
				this.neighbours.removeElement(na);
				this.checkNeighboursConsistency();
				_logger.info("NEIGHBOUR SIZE: " + this.neighbours.size());
				if (this.neighbours.size() == 0) {
					this.clock.count(false);
					this.jButton5.setEnabled(false);
					_logger.info("Removing QAPs...");
					for (int x = this.container.queryPanels.size() - 1; x >= 0; x--) {
						QueryAntPanel qap = (QueryAntPanel) this.container.queryPanels
								.remove(x);
						this.container.jTabbedPane1.remove(qap);
						this.warriorAnt.getPropertyChangeSupport()
								.removePropertyChangeListener(qap);
					}
					_logger.info("Removing DAP: " + this.container.dap);
					if (this.container.dap != null) {
						_logger.info("Interrupting downloads");
						this.container.dap.interruptAllDownloads();
						_logger.info("Interrupted!");
						this.container.jTabbedPane1.remove(this.container.dap);
						this.warriorAnt.getPropertyChangeSupport()
								.removePropertyChangeListener(
										this.container.dap);
						this.container.dap = null;
					}
					_logger.info("Removing UAP: " + this.container.uap);
					if (this.container.uap != null) {
						_logger.info("Interrupting uploads");
						this.container.uap.interruptAllUploads();
						_logger.info("Interrupted!");
						this.container.jTabbedPane1.remove(this.container.uap);
						this.warriorAnt.getPropertyChangeSupport()
								.removePropertyChangeListener(
										this.container.uap);
						this.container.uap = null;
					}
					/*
					 * 07-07-08 _logger.info("Removing HAP:
					 * "+this.container.httpPanel); if (this.container.httpPanel !=
					 * null) {
					 * this.container.jTabbedPane1.remove(this.container.httpPanel);
					 * this.warriorAnt.getPropertyChangeSupport().
					 * removePropertyChangeListener( this.container.httpPanel);
					 * this.warriorAnt.resetCurrentProxy();
					 * this.container.httpPanel = null; }
					 */
					if (container.animationPanel != null) {
						this.container.animationPanel.stop();
					}
					this.container.revalidate();
				}

				if (this.container != null
						&& this.container.jTabbedPane1 != null) {
					Component[] tabs = this.container.jTabbedPane1
							.getComponents();
					for (int x = 0; tabs != null && x < tabs.length; x++) {
						if (tabs[x] == this.container.connectionScrollPane) {
							if (this.neighbours.size() > 0) {
								this.container.jTabbedPane1
										.setIconAt(
												x,
												new LabelIcon(
														ji.JI.i("Connected")
																+ " ["
																+ ji.JI
																		.i("Peers")
																+ ": "
																+ this.neighbours
																		.size()
																+ "]",
														DoubleBuffer
																.getInstance()
																.getButton(19),
														this.container.connectionScrollPane));
							} else {
								this.container.jTabbedPane1
										.setIconAt(
												x,
												new LabelIcon(
														ji.JI
																.i("Wait! ANts is connecting..."),
														DoubleBuffer
																.getInstance()
																.getButton(19),
														this.container.connectionScrollPane));
							}
						}
					}
				}
			}
		}
		if (e.getPropertyName().equals("newNeighbour")) {
			synchronized (this) {
				if (this.neighbours.size() == 0) {
					this.clock.count(true);
					if (container.animationPanel != null) {
						this.container.animationPanel.init();
					}
				}
				this.checkNeighboursConsistency();
				this.neighbours.addElement(e.getNewValue());
				this.jButton5.setEnabled(true);
				if (this.container.queryPanels.size() == 0) {
					QueryAntPanel qap = new QueryAntPanel(this.container);
					this.container.queryPanels.add(qap);
					this.container.jTabbedPane1.add(qap, new LabelIcon(ji.JI
							.i("Search"), DoubleBuffer.getInstance().getButton(
							12), qap));
					this.warriorAnt.getPropertyChangeSupport()
							.addPropertyChangeListener(qap);
				}
				if (this.container.dap == null) {
					DownloadAntPanel dap = new DownloadAntPanel(this.container);
					this.container.dap = dap;
					this.container.jTabbedPane1.add(this.container.dap,
							new LabelIcon(dap.getDonwloadsOverallSpeed(),
									DoubleBuffer.getInstance().getButton(17),
									dap));
					this.warriorAnt.getPropertyChangeSupport()
							.addPropertyChangeListener(dap);
				}
				if (this.container.uap == null) {
					UploadAntPanel uap = new UploadAntPanel(this.container);
					this.container.uap = uap;
					this.container.jTabbedPane1.add(this.container.uap,
							new LabelIcon(this.container.uap
									.getUploadsOverallSpeed(), DoubleBuffer
									.getInstance().getButton(18),
									this.container.uap));
					this.warriorAnt.getPropertyChangeSupport()
							.addPropertyChangeListener(uap);
				}
				/*
				 * 07-07-08 if (this.container.httpPanel == null) { HttpAntPanel
				 * hap = new HttpAntPanel(this.container); ;
				 * this.container.httpPanel = hap;
				 * this.container.jTabbedPane1.add(this.container.httpPanel, new
				 * LabelIcon(ji.JI.i("Http Tunneling"),
				 * DoubleBuffer.getInstance().getButton(16),
				 * this.container.httpPanel));
				 * this.warriorAnt.getPropertyChangeSupport().
				 * addPropertyChangeListener(hap); }
				 */

				if (this.container != null
						&& this.container.jTabbedPane1 != null) {
					Component[] tabs = this.container.jTabbedPane1
							.getComponents();
					for (int x = 0; tabs != null && x < tabs.length; x++) {
						if (tabs[x] == this.container.connectionScrollPane) {
							this.container.jTabbedPane1
									.setIconAt(
											x,
											new LabelIcon(
													ji.JI.i("Connected")
															+ " ["
															+ ji.JI.i("Peers")
															+ ": "
															+ this.neighbours
																	.size()
															+ "]",
													DoubleBuffer.getInstance()
															.getButton(19),
													this.container.connectionScrollPane));
							break;
						}
					}
				}
			}
		}
		if (e.getPropertyName().equals("secureConnectionCreated")) {
			this.secureConnections.removeElement(((SecurityResponseMessage) e
					.getNewValue()).getSource().substring(0, 10));
			this.secureConnections.addElement(((SecurityResponseMessage) e
					.getNewValue()).getSource().substring(0, 10));
		}
		if (e.getPropertyName().equals("removedOutputSecureConnection")) {
			this.secureConnections.removeElement(((String) e.getNewValue())
					.substring(0, 10));
		}
		/*
		 * if (e.getPropertyName().equals("updatePacketCompressionStats")) {
		 * this.jLabel24.setText(NeighbourAnt.getTotalCompressionGainIn()+"%");
		 * this.jLabel26.setText(NeighbourAnt.getTotalCompressionGainOut()+"%");
		 * String in = NeighbourAnt.totalUncompressionSizeIn/MegaByte+""; in =
		 * in.substring(0,in.indexOf('.')+2); String out =
		 * NeighbourAnt.totalUncompressionSizeOut/MegaByte+""; out =
		 * out.substring(0,out.indexOf('.')+2); String downloaded =
		 * NeighbourAnt.totalDownloaded/MegaByte+""; downloaded =
		 * downloaded.substring(0,downloaded.indexOf('.')+2); String uploaded =
		 * NeighbourAnt.totalUploaded/MegaByte+""; uploaded =
		 * uploaded.substring(0,uploaded.indexOf('.')+2);
		 * this.jLabel27.setText(in+" Mb"); this.jLabel28.setText(out+" Mb");
		 * this.jLabel29.setText(downloaded+" Mb");
		 * this.jLabel30.setText(uploaded+" Mb"); }
		 */
		/*
		 * if (e.getPropertyName().equals("newANtsVersionDetected")) { String
		 * newerVersion = (String)e.getNewValue();
		 * FrameAnt.getInstance(null).setTitle(ji.JI.i("Ants P2P - NEW VERSION
		 * DETECTED")+": " + newerVersion + " "+ji.JI.i("PLEASE UPDATE")); }
		 */
	}

	public static void dumpFullPacketsStats() {
		_logger.info("Control[IN]: "
				+ (NeighbourAnt.totalControlCompressedSizeIn / MegaByte));
		_logger.info("Control[OUT]: "
				+ (NeighbourAnt.totalControlCompressedSizeOut / MegaByte));
		_logger.info("Query[IN]: "
				+ (NeighbourAnt.totalQueryCompressedSizeIn / MegaByte));
		_logger.info("Query[OUT]: "
				+ (NeighbourAnt.totalQueryCompressedSizeOut / MegaByte));
		_logger.info("Data[IN]: "
				+ (NeighbourAnt.totalDataCompressedSizeIn / MegaByte));
		_logger.info("Data[OUT]: "
				+ (NeighbourAnt.totalDataCompressedSizeOut / MegaByte));
	}

	void jButton3_actionPerformed(ActionEvent e) {
		try {
			this.jLabel5.setText(ji.JI.i("Connecting..."));
			if (this.jButton3.getToolTipText().equals(ji.JI.i("Start ANts"))) {
				this.jButton3.setEnabled(false);
				this.jCheckBox2.setEnabled(false);
				this.jCheckBox4.setEnabled(false);
				if (this.warriorAnt != null) {
					this.jLabel5.setText(ji.JI.i("Shutting down ANts..."));
					PrivateChatFrame.removeAllChats(this.warriorAnt);
					this.warriorAnt.disconnectWarrior();
				}
				if (this.connectionManager != null) {
					this.connectionManager.terminate();
					this.connectionManager = null;
				}
				/*
				 * if (this.ircBot != null) {
				 * this.jLabel5.setText(ji.JI.i("Shutting down IRC Bot..."));
				 * this.ircBot.shutdown(); }
				 */

				this.jLabel5.setText(ji.JI.i("Generating ID..."));
				AsymmetricProvider ap = new AsymmetricProvider(true);
				String antID = MessageSigner.getInstance().getPublicKey();

				this.jLabel5.setText(ji.JI.i("Initializing ANts..."));
				this.warriorAnt = new WarriorAnt(antID, Ant.maxNeighbours,
						Integer.parseInt(this.jTextField3.getText()),
						this.jCheckBox2.isSelected(), this
								.getLocalStringAddress(), this.jCheckBox4
								.isSelected());

				Thread.sleep(1000);
				if (!warriorAnt.isAlive()) {
					this.jLabel5.setText(ji.JI.i("ANts is not running..."));
					this.jLabel12.setText("ID:");
					throw new Exception(ji.JI.i("WarriorAnt not Started"));
				}

				this.jLabel5
						.setText(ji.JI.i("Initializing Address Crawler..."));
				InetAddressEngine.getInstance(warriorAnt);
				jLabel12.setText("ID: " + warriorAnt.getShortId());
				this.warriorAnt.getPropertyChangeSupport()
						.addPropertyChangeListener(this);

				jLabel5.setText(ji.JI.i("Initializing connection manager..."));
				this.connectionManager = new ConnectionManager(this);
				if (this.connectionManager != null) {
					this.warriorAnt.getPropertyChangeSupport()
							.addPropertyChangeListener(this.connectionManager);
					this.connectionManager.start();
				}

				jLabel5.setText(ji.JI.i("Running remote indexer..."));
				BackgroundEngine.getInstance().setWarriorAnt(this.warriorAnt);
				this.warriorAnt.propertyChangeSupport
						.addPropertyChangeListener(BackgroundEngine
								.getInstance());

				/* IrcBot Setup */
				/*
				 * if(!ConnectionAntPanel.ircServer.equals("")){ try{
				 * this.jLabel5.setText(ji.JI.i("Initializing IRC Bot..."));
				 * this.ircBot = new IrcBot(ConnectionAntPanel.nick, this);
				 * String password =
				 * this.container.sap.jPasswordField1.getText();
				 * if(!password.equals(""))
				 * this.ircBot.connect(ConnectionAntPanel.ircServer, 6667,
				 * password); else
				 * this.ircBot.connect(ConnectionAntPanel.ircServer);
				 * Thread.sleep(2000);
				 * this.ircBot.joinChannel(ConnectionAntPanel.ircChannel);
				 * Thread.sleep(3000);
				 * this.ircBot.refreshUsers(ConnectionAntPanel.ircChannel);
				 * //this.jButton9.setEnabled(true);
				 * jLabel23.setText(ji.JI.i("Your firewall is being
				 * probed...")); jLabel23.setToolTipText("<html><body>"+ji.JI.i("The
				 * test process for your port status is being performed...
				 * Please wait untill the port
				 * ")+this.warriorAnt.getServerPort()+" "+ji.JI.i("is tested")+"</body></html>");
				 * }catch(Exception ex){
				 * this.container.sap.setIrcConnected(false);
				 * this.container.sap.setIrcEnabled(false); _logger.error("IRC
				 * not started: "+ex.getMessage());
				 * if(ex.getMessage().toLowerCase().indexOf("nickname is already
				 * in use") >= 0) JOptionPane.showMessageDialog(this,
				 * ji.JI.i("Nickname is already in use"),ji.JI.i("Error in
				 * starting IRC"),JOptionPane.ERROR_MESSAGE); final SwingWorker
				 * worker = new SwingWorker() { public Object construct() {
				 * ircBot.autoReconnect(); return null; } }; worker.start(); }
				 * }else{ this.jLabel5.setText(ji.JI.i("No IRC Bot
				 * selected...")); this.container.sap.setIrcConnected(false);
				 * this.container.sap.setIrcEnabled(false); } /*Fine IrcBot
				 * setup
				 */

				if (this.container != null
						&& this.container.jTabbedPane1 != null) {
					Component[] tabs = this.container.jTabbedPane1
							.getComponents();
					for (int x = 0; tabs != null && x < tabs.length; x++) {
						if (tabs[x] == this.container.connectionScrollPane) {
							this.container.jTabbedPane1
									.setIconAt(
											x,
											new LabelIcon(
													ji.JI
															.i("Wait! ANts is connecting..."),
													DoubleBuffer.getInstance()
															.getButton(19),
													this.container.connectionScrollPane));
						}
					}
				}

				jLabel5.setText(ji.JI.i("ANts is listening on port") + ": "
						+ warriorAnt.getServerPort());
				this.jButton1.setEnabled(true);
				//this.jButton2.setEnabled(true);
				this.jButton3.setEnabled(true);
				jButton3.setIcon(new LabelIcon(ji.JI.i("Stop ANts"),
						DoubleBuffer.getInstance().getButton(11), jButton3));
				this.jButton3.setToolTipText(ji.JI.i("Stop ANts"));
				this.jButton4.setEnabled(true);
				this.jButton13.setEnabled(true);
				// this.jButton8.setEnabled(true);
				this.jTextField3.setEnabled(false);
				this.container.sap.jComboBox3.setEnabled(false);
				this.container.sap.jButton3.setEnabled(false);
				// this.container.sap.jButton2.setEnabled(true);
				this.container.sap.jButton4.setEnabled(false);
				this.propertyChangeSupport.firePropertyChange("antStarted",
						null, this);
			} else {
				this.jButton3.setEnabled(false);
				this.jLabel23.setText(ji.JI.i("Firewall probing idle"));
				this.jLabel23.setForeground(Color.RED);
				this.firewallChecked = false;
				if (this.warriorAnt != null) {
					PrivateChatFrame.removeAllChats(this.warriorAnt);
					this.warriorAnt.disconnectWarrior();
					BackgroundEngine.getInstance().setWarriorAnt(null);
					this.warriorAnt.propertyChangeSupport
							.removePropertyChangeListener(BackgroundEngine
									.getInstance());
					this.warriorAnt = null;
				}
				/*
				 * if (this.ircBot != null) { this.ircBot.shutdown();
				 * //this.jButton9.setEnabled(false);
				 * //this.container.sap.setIrcConnected(false);
				 * //this.container.sap.setIrcEnabled(false); }
				 */
				if (this.connectionManager != null) {
					this.connectionManager.terminate();
					this.connectionManager = null;
				}
				this.neighbours.removeAllElements();
				for (int x = this.container.queryPanels.size() - 1; x >= 0; x--) {
					QueryAntPanel qap = (QueryAntPanel) this.container.queryPanels
							.remove(x);
					this.container.jTabbedPane1.remove(qap);
				}
				if (this.container.dap != null) {
					this.container.jTabbedPane1.remove(this.container.dap);
					this.container.dap = null;
				}
				if (this.container.uap != null) {
					this.container.jTabbedPane1.remove(this.container.uap);
					this.container.uap = null;
				}
				jLabel5.setText(ji.JI.i("Ant is not running..."));
				this.jLabel12.setText("ID:");

				this.secureConnections.removeAllElements();
				Enumeration neighs = this.neighbours.elements();
				for (int x = this.neighbours.size() - 1; x >= 0; x++) {
					Object neigh = this.neighbours.get(x);
					// this.warriorAnt.removeNeighbour((NeighbourAnt)neigh);
					((NeighbourAnt) neigh).terminate();
					// this.neighbours.remove(x);
				}

				if (this.container != null
						&& this.container.jTabbedPane1 != null) {
					Component[] tabs = this.container.jTabbedPane1
							.getComponents();
					for (int x = 0; tabs != null && x < tabs.length; x++) {
						if (tabs[x] == this.container.connectionScrollPane) {
							this.container.jTabbedPane1
									.setIconAt(
											x,
											new LabelIcon(
													ji.JI.i("Hit Start ANts!"),
													DoubleBuffer.getInstance()
															.getButton(19),
													this.container.connectionScrollPane));
						}
					}
				}

				this.jButton1.setEnabled(false);
				//this.jButton2.setEnabled(false);
				jButton3.setIcon(new LabelIcon(ji.JI.i("Start ANts"),
						DoubleBuffer.getInstance().getButton(11), jButton3));
				this.jButton3.setToolTipText(ji.JI.i("Start ANts"));
				this.jButton3.setEnabled(true);
				this.jCheckBox2.setEnabled(true);
				this.jButton4.setEnabled(false);
				this.jButton13.setEnabled(false);
				// this.jButton8.setEnabled(false);
				this.jTextField3.setEnabled(true);
				// this.container.sap.jButton2.setEnabled(false);
				this.container.sap.jButton4.setEnabled(true);
				this.container.sap.jComboBox3.setEnabled(true);
				this.container.sap.jButton3.setEnabled(true);
				this.jCheckBox4.setEnabled(true);
				this.propertyChangeSupport.firePropertyChange("antStopped",
						null, this);
			}
		} catch (Exception ex) {
			if (this.warriorAnt != null) {
				this.warriorAnt.disconnectWarrior();
			}
			/*
			 * if (this.ircBot != null) { this.ircBot.shutdown(); }
			 */
			jLabel5.setText(ji.JI.i("Ant is not running..."));
			this.jLabel12.setText("ID:");
			this.jButton3.setEnabled(true);
			this.jCheckBox2.setEnabled(true);
			this.jCheckBox4.setEnabled(true);
			jButton3.setIcon(new LabelIcon(ji.JI.i("Start ANts"), DoubleBuffer
					.getInstance().getButton(11), jButton3));
			this.jButton3.setToolTipText(ji.JI.i("Start ANts"));

			this.jButton1.setEnabled(false);
			//this.jButton2.setEnabled(false);
			this.jButton4.setEnabled(false);
			this.jButton13.setEnabled(false);
			// this.jButton8.setEnabled(false);
			this.jTextField3.setEnabled(true);
			/*
			 * this.jButton9.setEnabled(false);
			 * this.container.sap.setIrcConnected(false);
			 * this.container.sap.setIrcEnabled(false);
			 * 
			 * this.container.sap.jButton2.setEnabled(false);
			 */
			this.container.sap.jButton4.setEnabled(true);
			this.container.sap.jComboBox3.setEnabled(false);
			this.container.sap.jButton3.setEnabled(false);

			this.propertyChangeSupport.firePropertyChange("antStopped", null,
					this);
			_logger.info(ji.JI.i("Ant is not running! ") + ex.getMessage());
			_logger.debug(ji.JI.i("Ant is not running! "), ex);

			JOptionPane
					.showMessageDialog(
							this,
							ji.JI
									.i("Error starting ANts. Try changing the default 443 port or closing the program that is using it!"),
							ji.JI.i("Error"), JOptionPane.ERROR_MESSAGE);
		}
	}

	void jButton1_actionPerformed(ActionEvent e) {
		try {
			this.warriorAnt.addP2PNeighbour(this.jTextField1.getText(), Integer
					.parseInt(this.jTextField2.getText()), true, FrameAnt
					.getInstance(null).getGuiAnt().getConnectionAntPanel()
					.getLocalInetAddress());
		} catch (Exception ex) {
			_logger.error("", ex);
		}
	}

	/*void jButton2_actionPerformed(ActionEvent e) {
		Object[] objects = this.jList1.getSelectedValues();
		for (int y = 0; y < objects.length; y++) {
			// this.warriorAnt.removeNeighbour((NeighbourAnt)objects[y]);
			_logger.info("Removing neighbour "
					+ ((NeighbourAnt) objects[y]).getIdent());
			this.warriorAnt
					.getNeighbour(((NeighbourAnt) objects[y]).getIdent())
					.terminate();
		}
	}*/

	void jButton4_actionPerformed(ActionEvent e) {
		Object[] objects = this.jList2.getSelectedValues();
		java.util.List outputSecure = this.container.cap.warriorAnt.outputSecureConnections;
		for (int y = 0; y < objects.length; y++) {
			for (int x = outputSecure.size() - 1; x >= 0; x--) {
				if (((EndpointSecurityManager) outputSecure.get(x)).getPeerId()
						.startsWith((String) objects[y])) {
					outputSecure.remove(x);
				}
			}
			this.secureConnections.removeElement(objects[y]);
		}
	}

	void jButton5_actionPerformed(ActionEvent e) {
		QueryAntPanel qap = new QueryAntPanel(this.container);
		this.container.queryPanels.add(qap);
		this.container.jTabbedPane1.add(qap, new LabelIcon(ji.JI.i("Search"),
				DoubleBuffer.getInstance().getButton(12), qap));
		this.container.cap.warriorAnt.getPropertyChangeSupport()
				.addPropertyChangeListener(qap);
	}

	void jButton6_actionPerformed(ActionEvent e) {
		if (this.container.sap != null) {
			this.container.jTabbedPane1.add(this.container.settingsScrollPane,
					new LabelIcon(ji.JI.i("Settings"), DoubleBuffer
							.getInstance().getButton(7),
							this.container.settingsScrollPane));
		}
	}

	void jButton7_actionPerformed(ActionEvent e) {
		if (this.container.dsap != null) {
			this.container.jTabbedPane1.add(this.container.dsap, new LabelIcon(
					ji.JI.i("Server & Router Settings"), DoubleBuffer
							.getInstance().getButton(11), this.container.dsap));
		}
	}

	/*
	 * public void refreshAndConnect(){ try { ArrayList peers =
	 * this.warriorAnt.getServersWithFreeSlots(InetAddress.
	 * getByName(this.jTextField5.getText()),
	 * Integer.parseInt(this.jTextField6.getText()),
	 * FrameAnt.getInstance(null).getGuiAnt().getConnectionAntPanel().getLocalInetAddress());
	 * this.warriorAnt.propertyChangeSupport.firePropertyChange("inetAddressQueryCompleted",
	 * null, peers); jList3.setListData(peers.toArray());
	 * ConnectionAntPanel.lastRoutingPoint = this.jTextField5.getText();
	 * ConnectionAntPanel.lastRoutingPointPort =
	 * Integer.parseInt(this.jTextField6.getText());
	 * this.container.sap.storeSettings(); for(int x = 0; x < peers.size() &&
	 * this.warriorAnt.getNeighboursNumber() <
	 * this.warriorAnt.getMaxNeighbours();x++){ try {
	 * this.warriorAnt.addP2PNeighbour( ( (ServerInfo)
	 * peers.get(x)).getAddress(). getHostAddress(), ( (ServerInfo)
	 * peers.get(x)).getPort(). intValue(), true, FrameAnt.
	 * getInstance(null).getGuiAnt(). getConnectionAntPanel().
	 * getLocalInetAddress()); Thread.sleep(10000); } catch (Exception e) {
	 * _logger.error("Failed adding neighbour: "+e.getMessage()); } } } catch
	 * (Exception ex) { _logger.error("Failed in retrieving peers infos from
	 * server: "+ex.getMessage()); try{ ServerInfo s = new ServerInfo("",
	 * this.jTextField5.getText(), new Integer(this.jTextField6.getText()),
	 * null); InetAddressEngine.removeDeadPeer(s); }catch(Exception ex1){
	 * _logger.info("Failed dear peer removal: "+ex.getMessage()); } } }
	 */

	static InetAddress searchForInternetPublicAddress(InetAddress[] addresses) {
		try {
			InetAddress publicAddress = null;
			for (int x = 0; x < addresses.length; x++) {
				byte head = addresses[x].getAddress()[0];
				byte body = addresses[x].getAddress()[1];
				byte tail = addresses[x].getAddress()[2];
				if (head >= 89 && head <= 127)
					continue;
				if (head >= 173 && head <= 187)
					continue;
				if (head >= 224 && head <= 239)
					continue;
				if (head >= 240 && head <= 255)
					continue;
				switch (head) {
				case (byte) 0:
					break;
				case (byte) 1:
					break;
				case (byte) 2:
					break;
				case (byte) 5:
					break;
				case (byte) 10:
					break;
				case (byte) 23:
					break;
				case (byte) 27:
					break;
				case (byte) 31:
					break;
				case (byte) 36:
					break;
				case (byte) 37:
					break;
				case (byte) 39:
					break;
				case (byte) 41:
					break;
				case (byte) 42:
					break;
				case (byte) 46:
					break;
				case (byte) 49:
					break;
				case (byte) 50:
					break;
				case (byte) 58:
					break;
				case (byte) 59:
					break;
				case (byte) 60:
					break;
				case (byte) 71:
					break;
				case (byte) 72:
					break;
				case (byte) 73:
					break;
				case (byte) 74:
					break;
				case (byte) 75:
					break;
				case (byte) 76:
					break;
				case (byte) 77:
					break;
				case (byte) 78:
					break;
				case (byte) 79:
					break;
				case (byte) 128:
					if (body == (byte) 0)
						break;
				case (byte) 169:
					if (body == (byte) 254)
						break;
				case (byte) 172:
					if (body >= (byte) 16 && body <= (byte) 31)
						break;
				case (byte) 189:
					break;
				case (byte) 190:
					break;
				case (byte) 191:
					if (body == (byte) 255)
						break;
				case (byte) 192:
					if (body == (byte) 0
							|| (body == (byte) 68 && tail == (byte) 185)
							|| body == (byte) 168)
						break;
				case (byte) 197:
					break;
				case (byte) 198:
					if (body >= (byte) 18 && body <= (byte) 19)
						break;
				case (byte) 223:
					break;
				default:
					publicAddress = addresses[x];
					break;
				}
			}
			return publicAddress;
		} catch (Exception e) {
			return null;
		}
	}

	public static boolean isInternetPublicAddress(InetAddress address) {
		try {
			byte head = address.getAddress()[0];
			byte body = address.getAddress()[1];
			byte tail = address.getAddress()[2];
			if (head >= 89 && head <= 127)
				return false;
			if (head >= 173 && head <= 187)
				return false;
			if (head >= 224 && head <= 239)
				return false;
			if (head >= 240 && head <= 255)
				return false;
			switch (head) {
			case (byte) 0:
				break;
			case (byte) 1:
				break;
			case (byte) 2:
				break;
			case (byte) 5:
				break;
			case (byte) 10:
				break;
			case (byte) 23:
				break;
			case (byte) 27:
				break;
			case (byte) 31:
				break;
			case (byte) 36:
				break;
			case (byte) 37:
				break;
			case (byte) 39:
				break;
			case (byte) 41:
				break;
			case (byte) 42:
				break;
			case (byte) 46:
				break;
			case (byte) 49:
				break;
			case (byte) 50:
				break;
			case (byte) 58:
				break;
			case (byte) 59:
				break;
			case (byte) 60:
				break;
			case (byte) 71:
				break;
			case (byte) 72:
				break;
			case (byte) 73:
				break;
			case (byte) 74:
				break;
			case (byte) 75:
				break;
			case (byte) 76:
				break;
			case (byte) 77:
				break;
			case (byte) 78:
				break;
			case (byte) 79:
				break;
			case (byte) 128:
				if (body == (byte) 0)
					break;
			case (byte) 169:
				if (body == (byte) 254)
					break;
			case (byte) 172:
				if (body >= (byte) 16 && body <= (byte) 31)
					break;
			case (byte) 189:
				break;
			case (byte) 190:
				break;
			case (byte) 191:
				if (body == (byte) 255)
					break;
			case (byte) 192:
				if (body == (byte) 0
						|| (body == (byte) 68 && tail == (byte) 185)
						|| body == (byte) 168)
					break;
			case (byte) 197:
				break;
			case (byte) 198:
				if (body >= (byte) 18 && body <= (byte) 19)
					break;
			case (byte) 223:
				break;
			default:
				return true;
			}
			return false;
		} catch (Exception e) {
			return false;
		}
	}

	public InetAddress getLocalInetAddress() {
		try {
			if (this.localStringAddress == null) {
				InetAddress[] addresses = InetAddress.getAllByName(InetAddress
						.getLocalHost().getHostName());
				InetAddress publicAddress = ConnectionAntPanel
						.searchForInternetPublicAddress(addresses);
				if (publicAddress != null) {
					this.localStringAddress = publicAddress.getHostAddress();
					return publicAddress;
				} else {
					this.localStringAddress = InetAddress.getLocalHost()
							.getHostAddress();
					return InetAddress.getLocalHost();
				}
			} else {
				return InetAddress.getByName(this.localStringAddress);
			}
		} catch (Exception e) {
			_logger.error("", e);
			return null;
		}
	}

	public String getLocalStringAddress() {
		this.getLocalInetAddress();
		return this.localStringAddress;
	}

	public void startANts() {
		this.jButton3_actionPerformed(new ActionEvent(this, 0, "Start ANts"));
	}

	public void updatetrustedpeersUI() {
		Object[] o = InetAddressEngine.getTrustedPeers().toArray();
		for (int i = 0; i < o.length; i++) {
			System.out.println(((ServerInfo) o[i]).toString());
		}
		// System.out.println(.toString());
		jList4.setListData(InetAddressEngine.getTrustedPeers().toArray());
	}

	public void updateStatsPanel(String value) {
		this.checkNeighboursConsistency();
		this.jLabel22.setText(value);
		this.jLabel24.setText(NeighbourAnt.getTotalCompressionGainIn() + "%");
		this.jLabel26.setText(NeighbourAnt.getTotalCompressionGainOut() + "%");
		String in = NeighbourAnt.totalUncompressionSizeIn / MegaByte + "";
		in = in.substring(0, in.indexOf('.') + 2);
		String out = NeighbourAnt.totalUncompressionSizeOut / MegaByte + "";
		out = out.substring(0, out.indexOf('.') + 2);
		String downloaded = NeighbourAnt.totalDownloaded / MegaByte + "";
		downloaded = downloaded.substring(0, downloaded.indexOf('.') + 2);
		String uploaded = NeighbourAnt.totalUploaded / MegaByte + "";
		uploaded = uploaded.substring(0, uploaded.indexOf('.') + 2);
		this.jLabel27.setText(in + " MB");
		this.jLabel28.setText(out + " MB");
		this.jLabel29.setText(downloaded + " MB");
		this.jLabel30.setText(uploaded + " MB");
	}

	/*
	 * void jButton8_actionPerformed(ActionEvent e) { try { ArrayList peers =
	 * this.warriorAnt.getServersWithFreeSlots(InetAddress.getByName(this.jTextField5.getText()),
	 * Integer.parseInt(this.jTextField6.getText()), FrameAnt.
	 * getInstance(null).getGuiAnt().getConnectionAntPanel().
	 * getLocalInetAddress()); jList3.setListData(peers.toArray());
	 * ConnectionAntPanel.lastRoutingPoint = this.jTextField5.getText();
	 * ConnectionAntPanel.lastRoutingPointPort =
	 * Integer.parseInt(this.jTextField6.getText());
	 * this.container.sap.storeSettings(); } catch (Exception ex) {
	 * _logger.error("",ex); } }
	 * 
	 * void jList3_mousePressed(MouseEvent e) {
	 * if(this.jList3.getSelectedValue() != null){ ServerInfo peer =
	 * (ServerInfo)this.jList3.getSelectedValue();
	 * this.jTextField1.setText(peer.getAddress().getHostAddress());
	 * this.jTextField2.setText(peer.getPort() + ""); } }
	 */
	/*
	 * void jButton9_actionPerformed(ActionEvent e) { try{ User[] users =
	 * this.ircBot.getUsers(ConnectionAntPanel.ircChannel);//this.ircBot.getActiveChannel());
	 * if(users.length > 1){ int userIndex = (int) (Math.random() *
	 * users.length); while (users[userIndex].equals(ConnectionAntPanel.nick) &&
	 * users.length > 1) { userIndex = (int) (Math.random() * users.length); }
	 * this.ircBot.sendCTCPCommand(users[userIndex].getNick(),
	 * "ANtsCommandCode:0000"); _logger.info("Sent request message to: " +
	 * users[userIndex].getNick()); } }catch(Exception ex){_logger.error("IRC
	 * Client not connected.",ex);} }
	 */
	/*
	 * void jTextField4_focusLost(FocusEvent e) { String newNick =
	 * this.jTextField4.getText(); if(this.jTextField4.getText().equals(""))
	 * newNick = "Def"+(int)(Math.random()*1000000); // //if(this.ircBot != null &&
	 * this.ircBot.isConnected()){ // this.ircBot.changeNick(newNick); //}else{
	 * this.jTextField4.setText(newNick); ConnectionAntPanel.nick =
	 * this.jTextField4.getText(); this.container.sap.storeSettings(); // } }
	 */
	/*
	 * public void setNick(String newNick) { if (newNick != null &&
	 * !newNick.equals("")) { this.jTextField4.setText(this.ircBot.getNick());
	 * ConnectionAntPanel.nick = this.ircBot.getNick();
	 * this.container.sap.storeSettings(); } }
	 */

	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		if (buffer != null) {
			int posX = (int) (this.getSize().getWidth() - 650) / 2;
			int posY = (int) (this.getSize().getHeight() - 550) / 2;
			if (posX < 0)
				posX = 0;
			if (posY < 0)
				posY = 0;
			g.drawImage(buffer, posX, posY, this);
		}
	}

	void jTextField3_focusLost(FocusEvent e) {
		try {
			int port = Integer.parseInt(this.jTextField3.getText());
			if (port <= 0 || port > 65536)
				throw new Exception("Invalid port number");
			this.container.sap.storeSettings();
		} catch (Exception ex) {
			this.jTextField3.setText("");
		}
	}

	void jTextField2_focusLost(FocusEvent e) {
		try {
			int port = Integer.parseInt(this.jTextField2.getText());
			if (port <= 0 || port > 65536)
				throw new Exception("Invalid port number");
		} catch (Exception ex) {
			this.jTextField2.setText("");
		}
	}

	/*
	 * void jTextField6_focusLost(FocusEvent e) { try { int port =
	 * Integer.parseInt(this.jTextField6.getText()); if (port <= 0 || port >
	 * 65536) throw new Exception("Invalid port number"); } catch (Exception ex) {
	 * this.jTextField6.setText(""); } }
	 */
	void this_componentResized(ComponentEvent e) {
		int limit;
		/*if (this.jCheckBox1.isSelected())
			limit = 600;
		else*/
			limit = 450;
		this.remove(this.jPanel2);
		this.jPanel2.remove(this.jPanel9);
		this.remove(this.jPanel3);
		this.remove(this.jPanel1);
		this.remove(this.jPanel4);
		int jPanel1PositionX = this.getWidth() - this.jPanel1.getWidth() - 40;
		if (jPanel1PositionX < limit)
			jPanel1PositionX = limit;
		this.jPanel2.setPreferredSize(new Dimension(jPanel1PositionX - 3,
				this.jPanel2.getHeight()));
		this.jPanel3.setPreferredSize(new Dimension(jPanel1PositionX - 3,
				this.jPanel3.getHeight()));
		this.jPanel4.setPreferredSize(new Dimension(jPanel1PositionX - 3, 335));
		this.jPanel9.setPreferredSize(new Dimension(jPanel1PositionX - 105,
				this.jPanel9.getHeight()));
		this.add(this.jPanel2, new XYConstraints(0, 0, -1, -1));
		this.jPanel2.add(this.jPanel9, new XYConstraints(95, 5, -1, -1));
		this.add(this.jPanel3, new XYConstraints(0,
				this.jPanel2.getHeight() + 3, -1, -1));
		this.add(this.jPanel1, new XYConstraints(jPanel1PositionX, 0, -1, -1));
		this.add(this.jPanel4, new XYConstraints(0, this.jPanel2.getHeight()
				+ this.jPanel3.getHeight() + 6, -1, -1));
	}

	void jButton10_actionPerformed(ActionEvent e) {
		if (this.container.shareap != null) {
			this.container.jTabbedPane1
					.add(this.container.shareap, new LabelIcon(ji.JI
							.i("Shared Files"), DoubleBuffer.getInstance()
							.getButton(6), this.container.shareap));
		}
	}

	void jButton11_actionPerformed(ActionEvent e) {
		try {
			if (this.jTextField7.getText() != null
					&& this.jTextField7.getText() != ""
					&& !this.jTextField8.equals("")) {
				InetAddress addr = InetAddress.getByName(this.jTextField7
						.getText());
				int port = Integer.parseInt(this.jTextField8.getText());
				InetAddressEngine.addTrustedPeer(this.jTextField7.getText(),
						port);
				this.jList4.setListData(InetAddressEngine.getTrustedPeers()
						.toArray());
			}
		} catch (Exception ex) {
			this.jTextField7.setText("");
		}
	}

	void jTextField8_focusLost(FocusEvent e) {
		try {
			int port = Integer.parseInt(this.jTextField8.getText());
			if (port <= 0 || port > 65536)
				throw new Exception("Invalid port number");
		} catch (Exception ex) {
			this.jTextField8.setText("");
		}
	}

	void jButton12_actionPerformed(ActionEvent e) {
		if (this.jList4.getSelectedValue() != null)
			InetAddressEngine.removeTrustedPeer((ServerInfo) this.jList4
					.getSelectedValue());
		this.jList4.setListData(InetAddressEngine.getTrustedPeers().toArray());
	}

/*	void jCheckBox1_actionPerformed(ActionEvent e) {
		if (this.jCheckBox1.isSelected() == true) {
			int confirm = JOptionPane
					.showConfirmDialog(
							this,
							ji.JI
									.i("The advanced tab should be used only by developers!\nDo you really want to access?"),
							ji.JI.i("Really?"), JOptionPane.OK_CANCEL_OPTION);
			if (confirm == JOptionPane.OK_OPTION) {
				this.jPanel4.setVisible(true);
			} else {
				this.jCheckBox1.setSelected(false);
			}
		} else {
			this.jPanel4.setVisible(false);
		}
	}
*/
	void jCheckBox2_actionPerformed(ActionEvent e) {
		if (this.jCheckBox2.isSelected() == true) {
			int confirm = JOptionPane
					.showConfirmDialog(
							this,
							ji.JI
									.i("You are entering the non-anonymous mode!\nThis will expose your IP address to other people.\nAre you sure?"),
							ji.JI.i("Attenction"), JOptionPane.OK_CANCEL_OPTION);
			if (confirm == JOptionPane.CANCEL_OPTION) {
				this.jCheckBox2.setSelected(false);
			}
		}
	}

	void jButton13_actionPerformed(ActionEvent e) {
		Object[] objects = this.jList2.getSelectedValues();
		java.util.List outputSecure = this.container.cap.warriorAnt.outputSecureConnections;
		for (int y = 0; y < objects.length; y++) {
			for (int x = outputSecure.size() - 1; x >= 0; x--) {
				if (((EndpointSecurityManager) outputSecure.get(x)).getPeerId()
						.startsWith((String) objects[y])) {
					PrivateChatFrame pcf = PrivateChatFrame.getChatWith(
							((EndpointSecurityManager) outputSecure.get(x))
									.getPeerId(), this.warriorAnt, true);
					pcf.show();
					pcf.transferFocus();
				}
			}
		}
	}

	public void showPCF(String peerId) {
		if (this.warriorAnt != null
				&& this.warriorAnt.getOutputSecureConnectionManager(peerId) != null) {
			PrivateChatFrame pcf = PrivateChatFrame.getChatWith(peerId,
					this.warriorAnt, true);
			pcf.setVisible(true);
			pcf.requestFocus();
			pcf.transferFocus();

		}
	}

	void jCheckBox3_actionPerformed(ActionEvent e) {
		if (this.jCheckBox3.isSelected()) {
			JDialog dialog = new JDialog(FrameAnt.getInstance(null), ji.JI
					.i("Proxy settings"), true);
			JLabel label = new JLabel("Insert your proxy data");
			label.setForeground(Color.BLUE);
			JLabel address = new JLabel("address");
			JTextField proxyAddress = new JTextField();
			proxyAddress.setPreferredSize(new Dimension(100, 23));
			JLabel port = new JLabel("port");
			JTextField proxyPort = new JTextField();
			proxyPort.setPreferredSize(new Dimension(50, 23));
			JButton okButton = new JButton("OK");
			okButton
					.addActionListener(new ConnectionAntPanel_okButton_actionAdapter(
							dialog, label, proxyAddress, proxyPort));
			JButton koButton = new JButton("Cancel");
			koButton
					.addActionListener(new ConnectionAntPanel_koButton_actionAdapter(
							dialog, (JCheckBox) e.getSource()));
			dialog.getContentPane().setLayout(new FlowLayout());
			dialog.getContentPane().add(label);
			dialog.getContentPane().add(address);
			dialog.getContentPane().add(proxyAddress);
			dialog.getContentPane().add(port);
			dialog.getContentPane().add(proxyPort);
			dialog.getContentPane().add(okButton);
			dialog.getContentPane().add(koButton);
			dialog.setLocation(new Point(200, 200));
			dialog.pack();
			dialog.setVisible(true);
		} else {
			Ant.setDirectConnection();
		}
		this.container.sap.storeSettings();
	}
}

class ConnectionAntPanel_okButton_actionAdapter implements
		java.awt.event.ActionListener {
	JTextField proxyAddress;
	JTextField proxyPort;
	JDialog dialog;
	JLabel label;

	ConnectionAntPanel_okButton_actionAdapter(JDialog dialog, JLabel label,
			JTextField proxyAddress, JTextField proxyPort) {
		this.proxyAddress = proxyAddress;
		this.proxyPort = proxyPort;
		this.dialog = dialog;
		this.label = label;
	}

	public void actionPerformed(ActionEvent e) {
		try {
			if (proxyAddress.getText().length() > 0
					&& proxyPort.getText().length() > 0) {
				InetAddress.getByName(proxyAddress.getText());
				Integer.parseInt(proxyPort.getText());
				Ant.setProxied(InetAddress.getByName(proxyAddress.getText()),
						Integer.parseInt(proxyPort.getText()));
				this.dialog.setVisible(false);
			} else {
				label.setText(ji.JI.i("Cannot set proxy!"));
				label.setForeground(Color.RED);
			}
		} catch (Exception ex) {
			label.setText(ji.JI.i("Cannot set proxy!"));
			label.setForeground(Color.RED);
		}
	}
}

class ConnectionAntPanel_koButton_actionAdapter implements
		java.awt.event.ActionListener {
	JDialog dialog;
	JCheckBox caller;

	ConnectionAntPanel_koButton_actionAdapter(JDialog dialog, JCheckBox caller) {
		this.dialog = dialog;
		this.caller = caller;
	}

	public void actionPerformed(ActionEvent e) {
		this.dialog.setVisible(false);
		this.caller.setSelected(false);
	}
}

class ConnectionAntPanel_jButton3_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jButton3_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		final ActionEvent event = e;
		final SwingWorker worker = new SwingWorker() {
			public Object construct() {
				adaptee.jButton3_actionPerformed(event);
				return null;
			}
		};
		worker.start();
	}
}

class ConnectionAntPanel_jButton1_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jButton1_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		final ActionEvent event = e;
		final SwingWorker worker = new SwingWorker() {
			public Object construct() {
				adaptee.jButton1_actionPerformed(event);
				return null;
			}
		};
		worker.start();
	}
}

/*class ConnectionAntPanel_jButton2_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jButton2_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		final ActionEvent event = e;
		final SwingWorker worker = new SwingWorker() {
			public Object construct() {
				adaptee.jButton2_actionPerformed(event);
				return null;
			}
		};
		worker.start();
	}
}*/

class ConnectionAntPanel_jButton4_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jButton4_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		adaptee.jButton4_actionPerformed(e);
	}
}

class ConnectionAntPanel_jButton5_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jButton5_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		adaptee.jButton5_actionPerformed(e);
	}
}

class ConnectionAntPanel_jButton6_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jButton6_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		adaptee.jButton6_actionPerformed(e);
	}
}

class ConnectionAntPanel_jButton7_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jButton7_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		adaptee.jButton7_actionPerformed(e);
	}
}

/*
 * class ConnectionAntPanel_jButton8_actionAdapter implements
 * java.awt.event.ActionListener { ConnectionAntPanel adaptee;
 * 
 * ConnectionAntPanel_jButton8_actionAdapter(ConnectionAntPanel adaptee) {
 * this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { final
 * ActionEvent event = e; final SwingWorker worker = new SwingWorker() { public
 * Object construct() { adaptee.jButton8_actionPerformed(event); return null; } };
 * worker.start(); } }
 */
/*
 * class ConnectionAntPanel_jList3_mouseAdapter extends
 * java.awt.event.MouseAdapter { ConnectionAntPanel adaptee;
 * 
 * ConnectionAntPanel_jList3_mouseAdapter(ConnectionAntPanel adaptee) {
 * this.adaptee = adaptee; } public void mousePressed(MouseEvent e) {
 * adaptee.jList3_mousePressed(e); } }
 */

/*
 * class ConnectionAntPanel_jButton9_actionAdapter implements
 * java.awt.event.ActionListener { ConnectionAntPanel adaptee;
 * 
 * ConnectionAntPanel_jButton9_actionAdapter(ConnectionAntPanel adaptee) {
 * this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) {
 * adaptee.jButton9_actionPerformed(e); } }
 */
/*
 * class ConnectionAntPanel_jTextField4_focusAdapter extends
 * java.awt.event.FocusAdapter { ConnectionAntPanel adaptee;
 * 
 * ConnectionAntPanel_jTextField4_focusAdapter(ConnectionAntPanel adaptee) {
 * this.adaptee = adaptee; } public void focusLost(FocusEvent e) { final
 * FocusEvent event = e; final SwingWorker worker = new SwingWorker() { public
 * Object construct() { adaptee.jTextField4_focusLost(event); return null; } };
 * worker.start(); } }
 */
class ConnectionAntPanel_jTextField3_focusAdapter extends
		java.awt.event.FocusAdapter {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jTextField3_focusAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void focusLost(FocusEvent e) {
		adaptee.jTextField3_focusLost(e);
	}
}

class ConnectionAntPanel_jTextField2_focusAdapter extends
		java.awt.event.FocusAdapter {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jTextField2_focusAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void focusLost(FocusEvent e) {
		adaptee.jTextField2_focusLost(e);
	}
}

/*
 * class ConnectionAntPanel_jTextField6_focusAdapter extends
 * java.awt.event.FocusAdapter { ConnectionAntPanel adaptee;
 * 
 * ConnectionAntPanel_jTextField6_focusAdapter(ConnectionAntPanel adaptee) {
 * this.adaptee = adaptee; } public void focusLost(FocusEvent e) {
 * adaptee.jTextField6_focusLost(e); } }
 */

class ConnectionAntPanel_this_componentAdapter extends
		java.awt.event.ComponentAdapter {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_this_componentAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void componentResized(ComponentEvent e) {
		adaptee.this_componentResized(e);
	}
}

class ConnectionAntPanel_jButton10_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jButton10_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		adaptee.jButton10_actionPerformed(e);
	}
}

class ConnectionAntPanel_jButton11_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jButton11_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		adaptee.jButton11_actionPerformed(e);
	}
}

class ConnectionAntPanel_jTextField8_focusAdapter extends
		java.awt.event.FocusAdapter {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jTextField8_focusAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void focusLost(FocusEvent e) {
		adaptee.jTextField8_focusLost(e);
	}
}

class ConnectionAntPanel_jButton12_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jButton12_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		adaptee.jButton12_actionPerformed(e);
	}
}

/*class ConnectionAntPanel_jCheckBox1_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jCheckBox1_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		adaptee.jCheckBox1_actionPerformed(e);
	}
}*/

class ConnectionAntPanel_jCheckBox2_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jCheckBox2_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		adaptee.jCheckBox2_actionPerformed(e);
	}
}

class ConnectionAntPanel_jButton13_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jButton13_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		adaptee.jButton13_actionPerformed(e);
	}
}

class ConnectionAntPanel_jCheckBox3_actionAdapter implements
		java.awt.event.ActionListener {
	ConnectionAntPanel adaptee;

	ConnectionAntPanel_jCheckBox3_actionAdapter(ConnectionAntPanel adaptee) {
		this.adaptee = adaptee;
	}

	public void actionPerformed(ActionEvent e) {
		adaptee.jCheckBox3_actionPerformed(e);
	}

}
